package com.hzlh.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.Properties;

@Slf4j
public class LhPropertiesUtils {

    private static Properties pro = new Properties();
    private static Properties proPro = new Properties();

    static {
        try {
            pro.load(LhPropertiesUtils.class.getClassLoader().getResourceAsStream("application.properties"));
            String proValue = getProValueBase("spring.profiles.active");
            proPro.load(LhPropertiesUtils.class.getClassLoader().getResourceAsStream("application-" + proValue + ".properties"));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            LOGGER.error("获取属性文件出错", e);
        }

    }

    public static String getProValue(String key) {
        return proPro.getProperty(key);
    }

    public static String getProValueBase(String key) {
        return pro.getProperty(key);
    }
}
